# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=procps-compat
pkgver=3.3.17
pkgrel=5
pkgdesc="Utilities for monitoring your system and processes on your system (compat old library)"
url="https://gitlab.com/procps-ng/procps"
arch="all"
license="GPL-2.0-or-later AND LGPL-2.1-or-later"
makedepends="
	autoconf
	automake
	gettext-dev
	libtool
	ncurses-dev
	"
checkdepends="dejagnu"
subpackages="$pkgname-dev $pkgname-libs"
source="https://gitlab.com/procps-ng/procps/-/archive/v$pkgver/procps-v$pkgver.tar.gz
	musl-fixes.patch
	dont-make-po.patch
	"
builddir="$srcdir/procps-v$pkgver"

prepare() {
	# NOTE: Name of the tarball's top-level directory contains SHA1.
	ln -fs $srcdir/$pkgname-v$pkgver-* "$builddir"

	default_prepare

	# force misc/git-version-gen use the correct version (instead of UNKNOWN);
	# however only do it if the upstream tarball really misses it.
	if test ! -f .tarball_version ; then
		rm -f .version
		echo "$pkgver" > .tarball-version
	fi
	./autogen.sh
}

build() {
	export LIBS="$LIBS -lintl"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--mandir=/usr/share/man \
		--sysconfdir=/etc \
		--docdir=/usr/share/doc/procps \
		--datarootdir=/usr/share \
		--disable-static \
		--disable-w-from \
		--disable-kill \
		--disable-rpath \
		--with-ncurses \
		--disable-modern-top
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" ldconfig=true install="install -D" \
		install

	# keep lib only
	# shellcheck disable=2115
	rm -rf \
		"$pkgdir"/usr/bin \
		"$pkgdir"/usr/sbin \
		"$pkgdir"/usr/share
}

sha512sums="
070076cf6bbbd8b6b342af361035f11d9c7381c5d1e2e430a5f2584ff55656254e8f863a40ca75a38870a5007d1b22a0d452bef13fa0ab89e4bf9676826fd788  procps-v3.3.17.tar.gz
54975d8fd87ff39551a04fb9f7ff6ffcec6fa2f7933a59c3f3d2b927cc0a21263259e864a9775a96f0996511f249fa72c1975010098fe12cff22202cdde1ed87  musl-fixes.patch
5624bcf70033a4020094200d487122258ad1c04fe8886aed3a8684ab52e4b2f46241c543ee5ede9ab23d9f0c7bc141cadc73f92151b33b6ff2bde017714bf6e4  dont-make-po.patch
"
